package views.inventory;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.border.BevelBorder;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.border.CompoundBorder;
import java.awt.Color;
import java.awt.event.ActionListener;

import javax.swing.UIManager;

public class AddNewCategory extends JPanel{
	private JTextField tAddCatName;
	private JComboBox tparentLevel;
	private JButton btnSave;
	private JTextField tEditCatName;
	private JButton btnUpdate;
	private JCheckBox chckbxMarkInactive;
	private Component seprator;
	private JComboBox cbId;
	
	public AddNewCategory() {
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		setPreferredSize(new Dimension(365, 550));
		setSize(350, 550);
		this.setMinimumSize(new Dimension(350, 550));
		this.setBackground(new Color(239,239,239));
		this.setMaximumSize(new Dimension(350, 550));
		
		JLabel lAddCatName = new JLabel("CATEGORY NAME:");
		springLayout.putConstraint(SpringLayout.NORTH, lAddCatName, 30, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lAddCatName, 30, SpringLayout.WEST, this);
		lAddCatName.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		//springLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, lAddCatName, 0, SpringLayout.HORIZONTAL_CENTER, this);
		add(lAddCatName);
		
		tAddCatName = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tAddCatName, 6, SpringLayout.SOUTH, lAddCatName);
		springLayout.putConstraint(SpringLayout.WEST, tAddCatName, 0, SpringLayout.WEST, lAddCatName);
		tAddCatName.setFont(new Font("Times New Roman", Font.PLAIN, 15));
		tAddCatName.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		add(tAddCatName);
		tAddCatName.setPreferredSize(new Dimension(250, 23));
		
		btnSave = new JButton("SAVE");
		btnSave.setActionCommand("SAVE");
		springLayout.putConstraint(SpringLayout.NORTH, btnSave, 25, SpringLayout.SOUTH,tAddCatName );
		springLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, btnSave, 0, SpringLayout.HORIZONTAL_CENTER, this);
		btnSave.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		add(btnSave);
		
		
		JSeparator separator = new JSeparator();
		springLayout.putConstraint(SpringLayout.NORTH, separator, 40, SpringLayout.SOUTH, btnSave);
		springLayout.putConstraint(SpringLayout.WEST, separator, 0, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, separator, 0, SpringLayout.EAST, this);
		add(separator);
		
		JLabel lEditCatName = new JLabel("CATEGORY NAME:");
		springLayout.putConstraint(SpringLayout.NORTH, lEditCatName, 30, SpringLayout.NORTH, separator);
		springLayout.putConstraint(SpringLayout.WEST, lEditCatName, 0, SpringLayout.WEST, lAddCatName);
		lEditCatName.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		add(lEditCatName);
		
		
		
		tEditCatName = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tEditCatName, 6, SpringLayout.SOUTH, lEditCatName);
		springLayout.putConstraint(SpringLayout.WEST, tEditCatName, 0, SpringLayout.WEST, lAddCatName);
		springLayout.putConstraint(SpringLayout.EAST, tEditCatName, 0, SpringLayout.EAST, tAddCatName);
		tEditCatName.setFont(new Font("Times New Roman", Font.PLAIN, 15));
		tEditCatName.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		add(tEditCatName);
		tEditCatName.setPreferredSize(new Dimension(250, 23));
	
		
		
		JLabel lAddCatLevel = new JLabel("CATEGORY PARENT ID:");
		springLayout.putConstraint(SpringLayout.NORTH, lAddCatLevel, 25, SpringLayout.SOUTH, tEditCatName);
		springLayout.putConstraint(SpringLayout.WEST, lAddCatLevel, 0, SpringLayout.WEST, tEditCatName);
		lAddCatLevel.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		add(lAddCatLevel);
		
		cbId = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, cbId, 6, SpringLayout.SOUTH, lAddCatLevel);
		springLayout.putConstraint(SpringLayout.WEST, cbId, 0, SpringLayout.WEST, lAddCatLevel);
		
		add(cbId);
		cbId.setPreferredSize(new Dimension(115, 23));
		
		chckbxMarkInactive = new JCheckBox("MARK INACTIVE");
		chckbxMarkInactive.setForeground(UIManager.getColor("InternalFrame.borderHighlight"));
		chckbxMarkInactive.setBackground(UIManager.getColor("InternalFrame.activeTitleGradient"));
		springLayout.putConstraint(SpringLayout.NORTH, chckbxMarkInactive, 25, SpringLayout.SOUTH, cbId);
		springLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, chckbxMarkInactive, 0, SpringLayout.HORIZONTAL_CENTER, this);
		chckbxMarkInactive.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		add(chckbxMarkInactive);
		
		btnUpdate = new JButton("UPDATE");
		btnUpdate.setActionCommand("UPDATE");
		springLayout.putConstraint(SpringLayout.NORTH, btnUpdate, 25, SpringLayout.SOUTH, chckbxMarkInactive);
		springLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, btnUpdate, 0, SpringLayout.HORIZONTAL_CENTER, this);
		btnUpdate.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		add(btnUpdate);
		
		
		springLayout.putConstraint(SpringLayout.EAST,this,30,SpringLayout.EAST,tAddCatName);
	
	}

	public JTextField gettAddCatName() {
		return tAddCatName;
	}

	public void settAddCatName(JTextField tAddCatName) {
		this.tAddCatName = tAddCatName;
	}

	public JComboBox getTparentLevel() {
		return tparentLevel;
	}

	public void setTparentLevel(JComboBox tparentLevel) {
		this.tparentLevel = tparentLevel;
	}

	public JButton getBtnSave() {
		return btnSave;
	}

	public void setBtnSave(JButton btnSave) {
		this.btnSave = btnSave;
	}

	public JTextField gettEditCatName() {
		return tEditCatName;
	}

	public void settEditCatName(JTextField tEditCatName) {
		this.tEditCatName = tEditCatName;
	}

	public JButton getBtnUpdate() {
		return btnUpdate;
	}

	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}

	public JCheckBox getChckbxMarkInactive() {
		return chckbxMarkInactive;
	}

	public void setChckbxMarkInactive(JCheckBox chckbxMarkInactive) {
		this.chckbxMarkInactive = chckbxMarkInactive;
	}

	public Component getSeprator() {
		return seprator;
	}

	public void setSeprator(Component seprator) {
		this.seprator = seprator;
	}

	public JComboBox getCbId() {
		return cbId;
	}

	public void setCbId(JComboBox cbId) {
		this.cbId = cbId;
	}
	public void actionlisteners(ActionListener al)
	{
		this.btnSave.addActionListener(al);
		this.btnUpdate.addActionListener(al);
	}
}
